<extend name="Layout:default"/>
<block name="title"><title>会员登录</title></block>
<block name="style">
<css href="/Public/Assets/Hui/lib/validator/jquery.validator.css"/>
<css href="/Public/Assets/Hui/lib/icheck/icheck.css"/>
<css href="/Public/Static/Js/jquery-yz/css/drag.css" />
<style>

</style>
</block>

<block name="main">
<div class="container clearfix">
	<div id="content-container">
		<div class="login-section" id="tab_login" class="HuiTab">
			  <div class="login-tab cl"><a class="current">登录账号</a><a href="{:U('register/index')}">注册账户</a></div>
			  <div class="login-con">
			  <form action="{:U('Login/login_post')}" method="post" class="validator_form">
			  	<div class="control-group mb-20">
			  		<label class="formlabel" for="">账号</label>
					<div class="formControls">
						<input type="text" class="input-text radius  size-L" value="" placeholder="用户名/手机/邮箱"  name="username" data-rule="账号:required;">
					</div>
			  	</div>
			  	<div class="control-group mb-30">
			  		<label class="formlabel" for="">密码</label>
					<div class="formControls">
						<input type="password" class="input-text radius  size-L" value="" placeholder="密码"  name="pwd" data-rule="密码:required;">
					</div>
			  	</div>
			  	<div class="control-group mb-20">
					<div id="drag"></div>
			  	</div>
			  	<div class="control-group mb-20">
					<div class="formControls">
						<label><input type="checkbox" name="_remember_me" checked="checked">记住密码</label>
					</div>
			  	</div>
			  	<div class="control-group mb-20">
			  		<div class="formControls">
			  			<input class="btn btn-primary btn-block radius size-L" type="submit" value="登录">
			  		</div>
			  	</div>
			  	</form>
			  	<div class="mb-20"><a href="{:U('resetpwd/index')}">找回密码</a><span class="pipe">|</span><span>还没有注册账号?</span><a href="{:U('register/index')}">立即注册</a></div>
			  	<div class="control-group mb-40 text-c connect">
			  		<if condition="C('REGISTER_SWITCH')">
			  			<if condition="!C('INVITATION_SWITCH')">
			  		 		{:W('Connect/index')}
			  		 	</if>
			  		 </if>
			  	</div>
			  </div>
		</div>
	</div>
</div>
</block>

<block name="script">
<js href="/Public/Assets/Hui/lib/validator/jquery.validator.js"/>
<js href="/Public/Assets/Hui/lib/validator/local/zh_CN.js"/>
<js href="/Public/Assets/Hui/lib/icheck/jquery.icheck.min.js"/>
<js href="/Public/Sea/modules/layer/2.1/layer/layer.js"/>
<js href="/Public/Static/Js/jquery-yz/js/drag.js" />
<script>
$('#drag').drag();

$('.validator_form').validator({
	msgClass: "n-bottom", 
	msgIcon:"",
    valid: function(form){
    	var me = this;
    	//防止重复提交表单
        me.holdSubmit();
        var ii = layer.msg('数据处理中...', {icon: 16,time: 10000}, function(){
	   	    layer.alert('服务器响应超时', {icon: 7});
	   	});
        
		$.ajax({
	        url:  $(form).attr('action'),
	        data: $(form).serialize(),
	        type: "POST",
	        dataType:"json",
	        success: function(data){
	        	layer.close(ii);
	        	//data = JSON.parse(data);  //str 转 json
	        	if (data.status) {
	        		layer.msg(data.info, {icon: 1,time:1000});
	            }else{
	            	layer.msg(data.info, {icon: 2,time:1000});
	            	me.holdSubmit(false);
	            }

	        	//需要跳转的话
	        	if(data.url){
	               	setTimeout(function(){
	               		location.href= data.url;
	               	},1000);
	            }else{
	            	embed_captcha.refresh();
	            }
	        	
	        	//信息提示框结束之后，表单可提交
	        	setTimeout(function(){
	        		me.holdSubmit(false);
	             },1000);
	        	
	        }
	    });
	}
});
</script>
</block>